package cn.tedu.controller2;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.w3c.dom.UserDataHandler;

import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

@RestController
@RequestMapping("user5")
public class TeacherController {
    @RequestMapping("save5")
    public void save5(
            Integer tno, String tname, String tsex, String tbirthday, String prof, String depart) throws Exception {
        System.out.println(tno+tname+tsex+tbirthday+prof+depart);
        Class.forName("com.mysql.jdbc.Driver");
        String url= "jdbc:mysql://localhost:3307/py-school-db?characterEncoding=utf8&amp;serverTimezone=Asia/Shanghai";
        Connection conn = DriverManager.getConnection(url,"root","123456");
        String sql = "insert into user values(?,?,?,?,?,?)";
        PreparedStatement ps = conn.prepareStatement(sql);
        ps.setInt(1,tno);
        ps.setString(2,tname);
        ps.setString(3,tsex);
        ps.setString(4,tbirthday);
        ps.setString(5,prof);
        ps.setString(6,depart);
        int rows=ps.executeUpdate();
        ps.close();
        conn.close();
    }
}
